﻿using Microsoft.Extensions.Options;

namespace 开发自己的配置提供者.自己练习;

public class MapWebConfigController
{
    private readonly IOptionsSnapshot<MapWebConfig> optWebConfig;

    public MapWebConfigController(IOptionsSnapshot<MapWebConfig> optWebConfig)
    {
        this.optWebConfig = optWebConfig;
    }

    public void Print()
    {
        var myConfig = optWebConfig.Value;
        string name = myConfig.ConfigName;
        string connStr = myConfig.Connstr1.ConnectionString;
        string providerName = myConfig.Connstr1.providerName;
        string server = myConfig.Smtp.Server;
        string port = myConfig.Smtp.Port;
        string pwd = myConfig.Smtp.Pwd;
        Console.WriteLine($"configName:{name}\r\nconnStr:{connStr}\r\nproviderName:{providerName}\r\nserver:{server}\r\nport:{port}\r\npwd:{pwd}");
    }
}